

/**
 * @Description:阶乘后的零 给定一个整数 n ，返回 n! 结果中尾随零的数量。
 * 提示 n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1
 * @Date:Create in 10:35  2022/6/15
 */
public class trailingZeroes0172 {

    public static void main(String[] args) {
        int n = 13;
        System.out.println(trailingZeroes1(n));
    }

    //数学解法
    public static int trailingZeroes1(int n) {
        int ans = 0;
        for (int i = 5; i <= n; i += 5) {
            for (int x = i; x % 5 == 0; x /= 5) {
                ++ans;
            }
        }
        return ans;

    }


    public static int trailingZeroes2(int n) {
        return 1;
    }
}
